package model

import (
	"database/sql"
	"time"

	"github.com/guregu/null"
	"github.com/satori/go.uuid"
)

var (
	_ = time.Second
	_ = sql.LevelDefault
	_ = null.Bool{}
	_ = uuid.UUID{}
)

/*
DB Table Details
-------------------------------------


CREATE TABLE purchase_order (
    id INTEGER NOT NULL,
    payment_id INTEGER NOT NULL,
    full_name TEXT NOT NULL,
    PRIMARY KEY (id, payment_id)
)

JSON Sample
-------------------------------------
{    "id": 2,    "payment_id": 74,    "full_name": "yKaUjopVmgNirKKOaalVHmuCC"}



*/

// PurchaseOrder struct is a row record of the purchase_order table in the main database
type PurchaseOrder struct {
	//[ 0] id                                             integer              null: false  primary: true   isArray: false  auto: false  col: integer         len: -1      default: []
	ID int32 `gorm:"primary_key;column:id;type:integer;" json:"id"`
	//[ 1] payment_id                                     integer              null: false  primary: false  isArray: false  auto: false  col: integer         len: -1      default: []
	PaymentID int32 `gorm:"column:payment_id;type:integer;" json:"payment_id"`
	//[ 2] full_name                                      text                 null: false  primary: false  isArray: false  auto: false  col: text            len: -1      default: []
	FullName string `gorm:"column:full_name;type:text;" json:"full_name"`
}

var purchase_orderTableInfo = &TableInfo{
	Name: "purchase_order",
	Columns: []*ColumnInfo{

		{
			Index:              0,
			Name:               "id",
			Comment:            ``,
			Notes:              ``,
			Nullable:           false,
			DatabaseTypeName:   "integer",
			DatabaseTypePretty: "integer",
			IsPrimaryKey:       true,
			IsAutoIncrement:    false,
			IsArray:            false,
			ColumnType:         "integer",
			ColumnLength:       -1,
			GoFieldName:        "ID",
			GoFieldType:        "int32",
			JSONFieldName:      "id",
			ProtobufFieldName:  "id",
			ProtobufType:       "int32",
			ProtobufPos:        1,
		},

		{
			Index:              1,
			Name:               "payment_id",
			Comment:            ``,
			Notes:              ``,
			Nullable:           false,
			DatabaseTypeName:   "integer",
			DatabaseTypePretty: "integer",
			IsPrimaryKey:       false,
			IsAutoIncrement:    false,
			IsArray:            false,
			ColumnType:         "integer",
			ColumnLength:       -1,
			GoFieldName:        "PaymentID",
			GoFieldType:        "int32",
			JSONFieldName:      "payment_id",
			ProtobufFieldName:  "payment_id",
			ProtobufType:       "int32",
			ProtobufPos:        2,
		},

		{
			Index:              2,
			Name:               "full_name",
			Comment:            ``,
			Notes:              ``,
			Nullable:           false,
			DatabaseTypeName:   "text",
			DatabaseTypePretty: "text",
			IsPrimaryKey:       false,
			IsAutoIncrement:    false,
			IsArray:            false,
			ColumnType:         "text",
			ColumnLength:       -1,
			GoFieldName:        "FullName",
			GoFieldType:        "string",
			JSONFieldName:      "full_name",
			ProtobufFieldName:  "full_name",
			ProtobufType:       "string",
			ProtobufPos:        3,
		},
	},
}

// TableName sets the insert table name for this struct type
func (p *PurchaseOrder) TableName() string {
	return "purchase_order"
}

// BeforeSave invoked before saving, return an error if field is not populated.
func (p *PurchaseOrder) BeforeSave() error {
	return nil
}

// Prepare invoked before saving, can be used to populate fields etc.
func (p *PurchaseOrder) Prepare() {
}

// Validate invoked before performing action, return an error if field is not populated.
func (p *PurchaseOrder) Validate(action Action) error {
	return nil
}

// TableInfo return table meta data
func (p *PurchaseOrder) TableInfo() *TableInfo {
	return purchase_orderTableInfo
}
